package com.vo;

import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * @author Sans
 * 统一结果的封装
 * 用于返回给前端的封装对象
 */
public class ResultVo<T> {
    // 分页对象
    private PageInfo<T> pageInfo;
    // 返回集合
    private List<T> list;
    // 返回单个对象
    private T obj;
    // 返回状态码
    private Integer code = 200;
    // 展示给用户的信息
    private String msg = "ok";
    
    private Integer status = 0;
    
    public ResultVo() {
    }
    
    public ResultVo(String msg , Integer status) {
        this.msg = msg;
        this.status = status;
    }
    
    public ResultVo(Integer code , String msg) {
        this.code = code;
        this.msg = msg;
    }
    
    //封装形式
    
    public ResultVo(List<T> list) {
        this.list = list;
    }
    
    public Integer getStatus() {
        return status;
    }
    
    public void setStatus(Integer status) {
        this.status = status;
    }
    
    public ResultVo(T obj) {
        this.obj = obj;
    }
    
    public ResultVo(PageInfo<T> pageInfo) {
        this.pageInfo = pageInfo;
    }
    
    public PageInfo<T> getPageInfo() {
        return pageInfo;
    }
    
    public void setPageInfo(PageInfo<T> pageInfo) {
        this.pageInfo = pageInfo;
    }
    
    public List<T> getList() {
        return list;
    }
    
    public void setList(List<T> list) {
        this.list = list;
    }
    
    public T getObj() {
        return obj;
    }
    
    public void setObj(T obj) {
        this.obj = obj;
    }
    
    public Integer getCode() {
        return code;
    }
    
    public void setCode(Integer code) {
        this.code = code;
    }
    
    public String getMsg() {
        return msg;
    }
    
    public void setMsg(String msg) {
        this.msg = msg;
    }
    
    @Override
    public String toString() {
        return "ResultVo{" +
                "pageInfo=" + pageInfo +
                ", list=" + list +
                ", obj=" + obj +
                ", code=" + code +
                ", msg='" + msg + '\'' +
                '}';
    }
}
